package cn.schoolwow.util.module.check.instance.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

public class CheckInstanceNotNullAnyFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        Object[] valueArray = flowContext.getData("valueArray", Object[].class);
        String message = (String) flowContext.checkData("message");

        if(null==valueArray||valueArray.length==0){
            throw new IllegalArgumentException(message+"不能都为空");
        }
        boolean hasNullValue = true;
        for(Object value:valueArray){
            if(null!=value){
                hasNullValue = false;
                break;
            }
        }
        if(hasNullValue){
            throw new IllegalArgumentException(message+"不能都为空");
        }
    }

    @Override
    public String name() {
        return "实例-检查NULL字段-任意一个字段不为空";
    }
}
